package com.ruoyi.wcf.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wcf.domain.WcfRegionManage;
import com.ruoyi.wcf.service.IWcfRegionManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 功能区管理Controller
 * 
 * @author LCL
 * @date 2022-04-06
 */
@RestController
@RequestMapping("/wcf/WcfRegionManage")
public class WcfRegionManageController extends BaseController
{
    @Autowired
    private IWcfRegionManageService wcfRegionManageService;

    /**
     * 查询功能区管理列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRegionManage:list')")
    @GetMapping("/list")
    public TableDataInfo list(WcfRegionManage wcfRegionManage)
    {
        startPage();
        List<WcfRegionManage> list = wcfRegionManageService.selectWcfRegionManageList(wcfRegionManage);
        return getDataTable(list);
    }

    /**
     * 导出功能区管理列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRegionManage:export')")
    @Log(title = "功能区管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WcfRegionManage wcfRegionManage)
    {
        List<WcfRegionManage> list = wcfRegionManageService.selectWcfRegionManageList(wcfRegionManage);
        ExcelUtil<WcfRegionManage> util = new ExcelUtil<WcfRegionManage>(WcfRegionManage.class);
        return util.exportExcel(list, "功能区管理数据");
    }

    /**
     * 获取功能区管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRegionManage:query')")
    @GetMapping(value = "/{regionId}")
    public AjaxResult getInfo(@PathVariable("regionId") Long regionId)
    {
        return AjaxResult.success(wcfRegionManageService.selectWcfRegionManageByRegionId(regionId));
    }

    /**
     * 新增功能区管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRegionManage:add')")
    @Log(title = "功能区管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WcfRegionManage wcfRegionManage)
    {
        return toAjax(wcfRegionManageService.insertWcfRegionManage(wcfRegionManage));
    }

    /**
     * 修改功能区管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRegionManage:edit')")
    @Log(title = "功能区管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WcfRegionManage wcfRegionManage)
    {
        return toAjax(wcfRegionManageService.updateWcfRegionManage(wcfRegionManage));
    }

    /**
     * 删除功能区管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfRegionManage:remove')")
    @Log(title = "功能区管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regionIds}")
    public AjaxResult remove(@PathVariable Long[] regionIds)
    {
        return toAjax(wcfRegionManageService.deleteWcfRegionManageByRegionIds(regionIds));
    }
}
